<?php

namespace App\Repositories\PayLog;

use Illuminate\Support\Facades\DB;
use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\PayLog\PayLogRepository;
use App\Models\PayLog\PayLog;
use App\Validators\PayLog\PayLogValidator;

/**
 * Class PayLogRepositoryEloquent.
 *
 * @package namespace App\Repositories\PayLog;
 */
class PayLogRepositoryEloquent extends BaseRepository implements PayLogRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return PayLog::class;
    }

    /**
    * Specify Validator class name
    *
    * @return mixed
    */
    public function validator()
    {

        return PayLogValidator::class;
    }


    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }


    /**
     * @author yangzhic
     * @param array $data
     * @return int
     * @throws \Prettus\Repository\Exceptions\RepositoryException
     */
    public function addPayLog(array $data){
        return DB::table($this->makeModel()->getTable())->insertGetId($data);
    }

    /**
     * @author yangzhic
     * @param $pay_log_id
     * @param array $data
     * @return int
     * @throws \Prettus\Repository\Exceptions\RepositoryException
     */
    public function updatePayLog($pay_log_id,array $data){
        return DB::table($this->makeModel()->getTable())
            ->where('log_id','=',$pay_log_id)
            ->update($data);
    }
}
